<script setup>
import { artGetChannelsService } from '@/api/article'
import { ref } from 'vue'

// 父传子
defineProps({
  modelValue: {
    type: [Number, String]
  },
  width: String
})
// 子传父通知父组件回显
const emit = defineEmits(['update:valueModel'])
// 获取文章分类
const channelList = ref([])
const getChannelList = async () => {
  const res = await artGetChannelsService()
  channelList.value = res.data.data
}
// 一进页面就触发
getChannelList()
</script>

<template>
  <el-select
    :modelValue="modelValue"
    @update:modelValue="emit('update:modelValue', $event)"
    :style="{ width }"
  >
    <el-option
      v-for="channel in channelList"
      :key="channel.id"
      :label="channel.cate_name"
      :value="channel.id"
    ></el-option>
  </el-select>
</template>
